//
//  ArbitrationDetailController.m
//  PASystem
//
//  Created by 刘沿 on 16/8/17.
//  Copyright © 2016年 czd. All rights reserved.
//

#import "ArbitrationDetailController.h"
#import "ArbitrationDetailModel.h"


@interface ArbitrationDetailController ()

@property (nonatomic,strong) NSMutableArray *dataArray;


@end

@implementation ArbitrationDetailController

-(NSMutableArray *)dataArray{
    if (_dataArray == nil) {
        
        _dataArray = [NSMutableArray array];
    }
    
    return _dataArray;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self loadData];
}

- (void)loadData{
    
    NSString * userId = [[NSUserDefaults standardUserDefaults]objectForKey:@"userId"];
    NSString * pwdId = [[NSUserDefaults standardUserDefaults]objectForKey:@"pwdId"];
    NSString * userHumber = [[NSUserDefaults standardUserDefaults]objectForKey:@"userHumber"];
    
    NSString *json = [NSString stringWithFormat:@"{'action': sszcMch,'service': %@, 'userName':'%@','password':'%@', 'vaueJson':'{userid :%@,id:%@}'}",_service,userId,pwdId,userHumber,self.ID];
    
    NSArray * array = @[@{@"arg0":json}];
    
    [HttpTools requestWithURL:BaseURL arrays:array method:Basemethod success:^(id JSON) {
        
        NSDictionary *dict = JSON[@"reason"];
        
        NSDictionary *dic = dict[@"attrs"];
        
        ArbitrationDetailModel *model = [ArbitrationDetailModel mj_objectWithKeyValues:dic];
        
        [self.dataArray addObject:model];
        
        [self.tableView reloadData];
        
    } failure:^(NSError *error) {
        
        
    }];
    
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return 18;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    ArbitrationDetailModel *model = self.dataArray.firstObject;
    
    if (indexPath.row == 0) {
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10,80, 40)];
        
        label.text = @"申请时间:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        NSString *string = model.APPLYTIME;
        NSDateFormatter *fmt = [[NSDateFormatter alloc] init];
        fmt.dateFormat = @"MMM d, yyyy HH:mm:ss aa";
        fmt.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en-US"];
        NSDate *date = [fmt dateFromString:string];
        NSDateFormatter *fm = [[NSDateFormatter alloc] init];
        fm.dateFormat = @"yyyy-MM-dd";
        NSString *selfYear = [fm stringFromDate:date];
        
        lbl2.text = selfYear;
        lbl2.textAlignment = NSTextAlignmentRight;
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
        
    }else if (indexPath.row == 1){
        
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 120, 40)];
        
        label.text = @"商贸仲裁类别:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        
        lbl2.text = model.TYPE;
        lbl2.textAlignment = NSTextAlignmentRight;
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
        
        
    }
    else if (indexPath.row == 2){
        
        
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 40)];
        
        label.text = @"申请人电话:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        lbl2.textAlignment = NSTextAlignmentRight;
        lbl2.text = model.PHONE;
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
        
        
    }
    else if (indexPath.row == 3){
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10,80, 40)];
        
        label.text = @"争议类型:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        lbl2.textAlignment = NSTextAlignmentRight;
        lbl2.text = model.NAME;
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
        
    }
    else if (indexPath.row == 4){
        
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 80, 40)];
        
        label.text = @"申请企业:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        lbl2.textAlignment = NSTextAlignmentRight;
        lbl2.text = model.PROPOSER;
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
    }
    else if (indexPath.row == 5){
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 160, 40)];
        
        label.text = @"申请企业地域来源:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        lbl2.textAlignment = NSTextAlignmentRight;
        lbl2.text = model.PROPOSERADDR;
        
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
        
    }
    else if (indexPath.row == 6){
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 40)];
        
        label.text = @"被申请企业:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        lbl2.textAlignment = NSTextAlignmentRight;
        lbl2.text = model.RESPONDENT;
        
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
        
    }
    else if (indexPath.row == 7){
        
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 180, 40)];
        
        label.text = @"被申请企业地域来源:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        lbl2.textAlignment = NSTextAlignmentRight;
        lbl2.text = model.RESPONDENTADDR;
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
    }
    else if (indexPath.row == 8){
        
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 80, 40)];
        
        label.text = @"联系电话:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        
//         lbl2.text = model
        lbl2.textAlignment = NSTextAlignmentRight;
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
    }
    else if (indexPath.row == 9){
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 140, 40)];
        
        label.text = @"标的物:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        lbl2.textAlignment = NSTextAlignmentRight;
        lbl2.text = model.BD;
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
        
    }
    else if (indexPath.row == 10){
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 140, 40)];
        
        label.text = @"争议金额(人民币):";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        lbl2.textAlignment = NSTextAlignmentRight;
        lbl2.text = model.MONEY;
        
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
        
    }
    else if (indexPath.row == 11){
        
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 80, 40)];
        
        label.text = @"仲裁机构:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        
        lbl2.text = model.MECHANISM;
        lbl2.textAlignment = NSTextAlignmentRight;
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
    }
    else if (indexPath.row == 12){
        
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 60, 40)];
        
        label.text = @"代理人:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        lbl2.textAlignment = NSTextAlignmentRight;
        lbl2.text = model.AGENT;
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        return cell;
    }else if (indexPath.row == 13){
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 120, 40)];
        
        label.text = @"仲裁费(人民币):";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        lbl2.textAlignment = NSTextAlignmentRight;
        lbl2.text = model.ARBITRATIONFEE;
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
        
    }else if (indexPath.row == 14){
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 160, 40)];
        
        label.text = @"仲裁费返还(人民币):";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        lbl2.textAlignment = NSTextAlignmentRight;
        lbl2.text = model.RETURNMONEY;
        
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
        
    }else if (indexPath.row == 15){
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 100, 40)];
        
        label.text = @"中心所收取:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        
        lbl2.text = model.CENTERCHARGE;
        lbl2.textAlignment = NSTextAlignmentRight;
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
        
    }else if (indexPath.row == 16){
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 80, 40)];
        
        label.text = @"电子邮箱:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        
        lbl2.text = model.EMAIL;
        lbl2.textAlignment = NSTextAlignmentRight;
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
        
    }else if (indexPath.row == 17){
        UITableViewCell* cell = [[UITableViewCell alloc]init];
        
        UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10, 10, 40, 40)];
        
        label.text = @"其他:";
        
        label.font = [UIFont systemFontOfSize:15];
        
        [cell.contentView addSubview:label];
        
        UILabel *lbl2 = [[UILabel alloc] init];
        
        lbl2.font = [UIFont systemFontOfSize:15];
        
        lbl2.text = model.CONTENT;
        lbl2.textAlignment = NSTextAlignmentRight;
        [cell.contentView addSubview:lbl2];
        
        [lbl2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(label.mas_centerY);
            make.left.equalTo(label.mas_right);
            make.height.equalTo(label.mas_height);
            make.right.equalTo(cell.contentView.mas_right);
        }];
        
        
        return cell;
        
    }else{
        
        return nil;
        
    }


}




@end
